<?php
/**
 * Commodity.php
 * Created by PhpStorm.
 * User: 江小波
 * Date: 2019/6/11
 * Time: 15:53
 */
namespace app\console\command;

class Commodity extends Base
{
    protected function getCmdName()
    {
        return 'commodity';
    }
    protected function getCmdDescription()
    {
        return 'commodity cmd';
    }
    protected function processResult($result)
    {
        return $result;
    }

    /**
     * 命令行执行
     */
    // php cmd commodity --action saveTest
    public function saveTest()
    {
        // 创建商店
        $data = [
            'is_enable' => '1',
            'name' => '测试商店',
            'logo' => 'logo'
        ];
        $save = new \app\api\open\store\Save($data);
        $store = $save->index();
        // 创建供应商
        $data = [
            'is_enable' => '1',
            'name' => '测试供应商',
            'store_id' => $store['id'],
        ];
        $save = new \app\api\open\supplier\Save($data);
        $supplier = $save->index();
        // 商品
        $data = [
            'store_id' => $store['id'],
            'supplier_id' => $supplier['id'],
            'brand_id' => '1',
            'brand_name' => '母婴用品-强生',
            'category1'=>'1',
            'category2'=>'58',
            'category3'=>'68',
            'category1_name'=>'数码办公',
            'category2_name'=>'手机通讯',
            'category3_name'=>'手机',
            'title' => '简雅 不锈钢餐具',
            'title_color' => '#ff0000',
            'model' => '型号',
            'region_type' => '1',
            'inventory' => '2',
            'inventory_unit' => '个',
            'images' => 'http://yanxuan.nosdn.127.net/20c0362546ea059e80e79717273d36c2.png',
            'original_price' => '55.00',
            'min_original_price' => '45.00',
            'max_original_price' => '55.00',
            'price' => '69.00',
            'min_price' => '66.00',
            'max_price' => '70.00',
            'give_integral' => '10',
            'buy_min_number' => '1',
            'buy_max_number' => '9',
            'is_deduction_inventory' => '1',
            'is_shelves' => '1',
            'is_home_recommended' => '0',
            'home_recommended_images' => '',
            'content_web' => '<p><img src="http://yanxuan.nosdn.127.net/7f073d15efbe130d9961ccf7cca12603.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/dc96dcf2b2d3e49dbe99574e09addd4e.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/502f5ae65ebb5da83cf4b969a99b2032.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/3a869e93e23d12d7660d94575a143344.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/683190dc3b8414800eeaa18fa55b13ef.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/87ec3327ff3a8c4e7538bf60ba3ff33e.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b70e6376f8159a5070f7fbafbe90345e.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/d4fa71032db5a0485640b16dbd2b20f6.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/28c925c7a3b784caac786203e37c2455.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/65b9db31ea05d9c659af1aabea9d55c6.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/31d826a02cc265d19f64a8068da41160.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/60b4b75cab5481a01448b16fc383ee68.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/c0fa9e7dd24eb00de8e934c56fbf82b9.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/0c1e963af0cfa3663e9f85cbee564ab2.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/2f477c6f417e4596378aa2d22069eadf.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/0cc7624940b3f825a85ca97547b976a5.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/34dc178feb53db308538846b2d2754cc.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/4b53e3ae721094ffe9ab999dbfacd49b.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/29f210e5748b87c3f98aec38b98cfe3c.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/cf9534cdc65a41b1aa6a060e5a499225.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/f78a0e4c3a5261cdc66df2db6da3e640.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/fb2e4f79ed7c4e9144f29f4314ec5194.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/ba23858480087e3dcf609c809df9d067.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b63f173477adf1338e21c5b2d833cdc6.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/d19cb8805f1c8681fedc2c5434cf2ef5.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b4e21fc56dbc9384196bfed78c8de55a.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/ab16cf2aa672e1931d5f923763b96b9e.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/5f40b0379b69ed4ac1997a4200ef0917.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/30974def0bd7c88e48769f084fa13d86.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/cb3d6f396a2068447fa30587f07a9e6b.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/c68a2322b60f13c545f7a794e97bdf15.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/41185576f184bc7eb6a8f3c42c77dfa1.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/2fd61ce4a464d21e1396fe959814d457.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/5b1bec19bbbd2f45a1b6c330f0126991.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/e9ac7a07fd584226e24c78fd0dffa8da.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/bcc686661502ca61a22869d1468ea286.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/4331972d1fe30b704bc908200ff3ac99.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b30dece3233337a0b21296c6ece5de84.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/03cb03edea4c3cdd50a216eeba78079e.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b98f9060c97e02b1798d573daa34e0d8.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/a4ec6fbf0e0f63ead3ac56fb559ed69a.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/e963e2ac1b39eef380161acc57c565c2.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/efe9b77e52e108890ced5b854061cbf5.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/06d96f313c2589d24c2ffe5d5e966013.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b9a37c455ec440fe494b46e0a0c9448a.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/ea9867ad1bce905db27c564fd7d07da5.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/f9fabf4c89ea541637e41e26b0d4f80d.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/3947828f3fe4ede7cbf21a2574b733e6.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/7e17b1be6bf36224696cd6f3631f607c.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/db0d0434e4a4397e39e9aba2429b1c00.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/3d6734dfa8a93b9ac08976e8733de350.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/579be094e2b54ac2e76ab260bb420e2f.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/0a60d14ae3f6c134f99301bc9b5e84cd.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/627860548306cadeebebe40651c10af7.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/a536f590a50334429784c3e3e0aa518c.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/2ecf02ab492ef6ae207f2405c641be8c.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/217e50017d1737da59f8ac8707583db0.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/e407cfa63ed27db28d4df5a1f9350d2f.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/ffef14bf3be57711cad9152cf62c411c.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/df4df3c6da62bee7d9be7146e51004c8.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/4acd556b15ef87a498a93e3d9898c8a5.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/1ff38f426e6f769b46bc3d3109a79396.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/c0ffc2120a80425b6b525b37b3ba7476.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/ae42d6daab2b567c7418b6fe1e97d9b3.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/2cbb4eb6278c04295642f4ef954e0fbb.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b3f933d800fd37aa0f95193ca25ce49a.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/84604c6b317e2af2c9a784dd3eb71957.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/76929d6a19f98d33f6918571fdf7cb30.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/b9cee219b888f80dfd96d327ea6e3a39.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/3ab7ca80c0e118109f8ca727f1b2b6ea.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/1e5535debb6c7e32bd4fefe59c1f1118.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/15ebe953c5f747c5d44032c2c121e797.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/fcb6b9e4f098ab166279ccfd2ad2643f.jpg"/></p><p><img src="http://yanxuan.nosdn.127.net/391455249dfd6469776ac28f104fe751.jpg"/></p><p><br/></p>',
            'photo_count' => '0',
            'sales_count' => '0',
            'access_count' => '0',
            'attr_list' => '[]',
            'region_list' => '[]',
            'photo_list' => '[]',
            'cols' => json_encode([['value'=>'颜色'],['value'=>'尺寸']]),
            'rows' => json_encode([
                [
                    'cols' => ['白色','XL'],
                    'price' => '68.00',
                    'inventory' => '1',
                    'weight' => '0.10',
                    'coding' => '00001',
                    'barcode' => '00001',
                    'images' => 'http://yanxuan.nosdn.127.net/20c0362546ea059e80e79717273d36c2.png',
                    'is_shelves' => '1',
                    'original_price' => '55'
                ],
                [
                    'cols' => ['红色','L'],
                    'price' => '67.00',
                    'inventory' => '1',
                    'weight' => '0.10',
                    'coding' => '00002',
                    'barcode' => '00002',
                    'images' => 'http://yanxuan.nosdn.127.net/20c0362546ea059e80e79717273d36c2.png',
                    'is_shelves' => '1',
                    'original_price' => '54'
                ]
            ])
        ];
        $save = new \app\api\open\commodity\Save($data);
        $res = $save->index();
        echo json_encode($res);
    }
}